#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstring>
#define int long long
#define endl '\n'
using namespace std;
inline int read(){
    int x(0),f(1);
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        if(ch=='-')f=-1;
        ch=getchar();
    }
    while('0'<=ch&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    return x*f;
}
inline void write(int x){
    if(x==0){putchar('0');return;}
    if(x<0)putchar('-'),x=-x;
    int buf[1005],len(0);
    while(x)buf[len++]=x%10,x/=10;
    while(len)putchar(buf[--len]+'0');
}
struct Car{
    long  double l,r; //it describes that [l,r] is over-speed
    bool operator<(const Car &lhs)const{
        return l<lhs.l;
    }
}car[100005],car2[100005];
int p[100005];
int t,len,len2,n,m,L,V;
void Get(){
    len=len2=n=m=L=V=0;
    memset(car,0,sizeof car); memset(car2,0,sizeof car2); memset(p,0,sizeof p);
    n=read(),m=read(),L=read(),V=read();
    for(int i=1;i<=n;i++){
        int d=read(),v=read(),a=read();
        if(a>0){
            if(v>V) car[++len]={(long  double)d,(long  double)(L+1)};
            else if(v==V){
                if(d!=L) car[++len]={(long double)d+0.00001,(long double)(L+1)};
            }else{
                long double to=(long double)(V+v)*(long double)(V-v)/(long double)(2.0*a)+d;
                if(to<=L) {
                    if((int)(to+0.00001)==(int)(to)) car[++len]={to+0.00001,(long double)(L+1)};
                    else car[++len]={to,(long double)(L+1)};
                }
            }
        } else if(a==0){
            if(v>V) car[++len]={(long double)d,(long double)(L+1)};
        } else {
            if(v>V) {
                long double to=(long double)(V+v)*(long double)(V-v)/(long double)(2.0*a)+d;
                if(ceil(to-0.00001)==ceil(to)) car[++len]={(long double)d,to-0.00001};
                else car[++len]={(long double)d,to};
            }
        }
    }
    sort(car+1,car+1+len);
    int j(1);
    for(int i=1;i<=m;i++){
        p[i]=read();
        while(car[j].l<=p[i]&&p[i]<=car[j].r) car2[++len2]=car[j++];
        while(car[j].r<p[i]&&j<=len)j++;
    }
    cout<<len2<<' ';
    return ;
}
void solve(){
    int i(1),j(1),ans(0),lst(0);
    while(i<=len2&&j<=m){
        if(!lst){
            lst=car2[i].r;
            while(p[j]<car2[i].r&&j<=m)j++;
            while(car2[i].r<p[j]||j>m)j--;
        }
        else{
            if(car2[i].r <= lst){
                lst=car2[i].r;
                while(p[j]<car2[i].r&&j<=m)j++;
                while(car2[i].r<p[j]||j>m)j--;
            }else if(car2[i].r > lst){
                if(car2[i].l <= lst){
                    if(p[j]<=car2[i].l||lst<=p[j]){
                        ans++;
                        lst=car2[i].r;
                        while(p[j]<car2[i].r&&j<=m)j++;
                        while(car2[i].r<p[j]||j>m)j--;
                    }
                }else{
                    ans++;
                    lst=car2[i].r;
                    while(p[j]<car2[i].r&&j<=m)j++;
                    while(car2[i].r<p[j]||j>m)j--;
                }
            }
        }
        i++;
    }
    if(car2[i-1].l<=p[j]&&p[j]<=car2[i-1].r)ans++;
    cout<<m-ans;
}
signed main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    t=read();
    while(t--){
        Get();
        solve();
        cout<<endl;
    }
    return 0;
}
